{
  // Default options
  'functions': true,
  'variableNameTransforms': ['dasherize']
}

{{#block "sprites-comment"}}
/*
LESS variables are information about icon's compiled state, stored under its original file name

.icon-home {
  width: @icon-home-width;
}

The large array-like variables contain all information about a single icon
@icon-home: x y offset_x offset_y width height total_width total_height image_path name;

At the bottom of this section, we provide information about the spritesheet itself
@spritesheet: width height image @spritesheet-sprites;
*/
{{/block}}
{{#block "sprites"}}
{{#each sprites}}
@{{strings.name_name}}: '{{name}}';
@{{strings.name_x}}: {{px.x}};
@{{strings.name_y}}: {{px.y}};
@{{strings.name_offset_x}}: {{px.offset_x}};
@{{strings.name_offset_y}}: {{px.offset_y}};
@{{strings.name_width}}: {{px.width}};
@{{strings.name_height}}: {{px.height}};
@{{strings.name_total_width}}: {{px.total_width}};
@{{strings.name_total_height}}: {{px.total_height}};
@{{strings.name_image}}: '{{{escaped_image}}}';
@{{strings.name}}: {{px.x}} {{px.y}} {{px.offset_x}} {{px.offset_y}} {{px.width}} {{px.height}} {{px.total_width}} {{px.total_height}} '{{{escaped_image}}}' '{{name}}';
{{/each}}
{{/block}}
{{#block "spritesheet"}}
@{{spritesheet_info.strings.name_width}}: {{spritesheet.px.width}};
@{{spritesheet_info.strings.name_height}}: {{spritesheet.px.height}};
@{{spritesheet_info.strings.name_image}}: '{{{spritesheet.escaped_image}}}';
@{{spritesheet_info.strings.name_sprites}}:{{#each sprites}} @{{strings.name}}{{/each}};
@{{spritesheet_info.strings.name}}: {{spritesheet.px.width}} {{spritesheet.px.height}} '{{{spritesheet.escaped_image}}}' @{{spritesheet_info.strings.name_sprites}};
{{/block}}

{{#block "sprite-functions-comment"}}
{{#if options.functions}}
/*
The provided classes are intended to be used with the array-like variables

.icon-home {
  .sprite-width(@icon-home);
}
.icon-email {
  .sprite(@icon-email);
}

Example usage in HTML:

`display: block` sprite:
<div class="icon-home"></div>

To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:

// CSS
.icon {
  display: inline-block;
}

// HTML
<i class="icon icon-home"></i>
*/
{{/if}}
{{/block}}
{{#block "sprite-functions"}}
{{#if options.functions}}
.sprite-width(@sprite) {
  width: extract(@sprite, 5) / 2;
}

.sprite-height(@sprite) {
  height: extract(@sprite, 6) / 2;
}

//  nth是指#block "sprites"第几个参数，可以输出$sprite来查看,
.sprite-position(@sprite) {
  @sprite-offset-x: extract(@sprite, 3);
  @sprite-offset-y: extract(@sprite, 4);
  background-position: @sprite-offset-x / 2 @sprite-offset-y / 2;
  background-size: extract(@sprite, 7) / 2 auto;
}

.sprite-image(@sprite) {
  {{! DEV: We slice to trim off excess quotes on an escaped URL }}
  @sprite-image: extract(@sprite, 9);
  @sprite-image-bare: ~`"@{sprite-image}".slice(1, -1)`;
  background-image: url(@sprite-image-bare);
}

.sprite(@sprite) {
  .sprite-image(@sprite);
  .sprite-position(@sprite);
  .sprite-width(@sprite);
  .sprite-height(@sprite);
}
{{/if}}
{{/block}}

{{#block "spritesheet-functions-comment"}}
{{#if options.functions}}
/*
The `.sprites` mixin generates identical output to the CSS template
  but can be overridden inside of LESS

This must be run when you have at least 2 sprites.
  If run with a single sprite, then there will be reference errors.

.sprites(@spritesheet-sprites);
*/
{{/if}}
{{/block}}
{{#block "spritesheet-functions"}}
{{#if options.functions}}
.sprites(@sprites, @i: 1) when (@i <= length(@sprites)) {
  @sprite: extract(@sprites, @i);
  @sprite-name: e(extract(@sprite, 10));
  .@{sprite-name} {
    .sprite(@sprite);
  }
  .sprites(@sprites, @i + 1);
}
{{/if}}
{{/block}}
